import Vue from 'vue';
const MESSAGES_UPDATED = (state: any, messages: any) => {
  state.messages = messages;
};

const updatelist = (state: any, config: any) => {
  let _editIndex = -1
  state.list.forEach((element: any, index: number) => {
    if (element._id == config._id) {
      // 修改
      _editIndex = index
    }
  })
  if (_editIndex != -1) {
    Vue.set(state.list, _editIndex, config)
  }
}

// 删除连接
const removeconnect = (state: any, data: any) => {
  let _editIndex = -1
  state.list.forEach((element: any, index: number) => {
    if (element._id == data._id) {
      // 修改
      _editIndex = index
    }
  })
  if (_editIndex != -1) {
    Vue.delete(state.list, _editIndex)
  }
}

export default {
  MESSAGES_UPDATED,
  updatelist,
  removeconnect
};
